<?php

namespace api\modules\ua\controllers;


use yii;
use yii\rest\ActiveController;
use yii\web\Response;

class DemoController extends ActiveController
{
    public $modelClass   = 'api\modules\avalon\models\User';
    public $app_prefix = 'ua';

    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['contentNegotiator']['formats'] = ['application/json' => Response::FORMAT_JSON];
        return $behaviors;
    }

    public function actions()
    {
        $actions = parent::actions();
        // 注销系统自带的实现方法
        unset($actions['index'], $actions['update'], $actions['create'], $actions['delete'], $actions['view']);
        return $actions;
    }

    public function actionVersion(){
        $data['code'] = 10000;
        $data['data'] = [
            "homePageVersion"           => "1.1.6",
            "redemptionModuleVersion"   => "1.1.6"
        ];

        $cache = Yii::$app->cache;
        $cache->set('cache','redis cache..', 60);
        $data['cache'] = $cache->get('cache');

        return $data;
    }

    public function actionPromotion(){
        $data['code'] = 10000;
        $data['data'] = [
            "campaignId"    => "1011",
            "endAt"         => "2025-04-20T23:59:59+08:00",
            "title"         => "传奇礼遇",
            "subtitle"      => "出手为敬",
            "picUrl"        => "https://sh-oss-n.oss-cn-shanghai.aliyuncs.com/ua/promotion.jpg",
            "picUrlThumb"   => "https://sh-oss-n.oss-cn-shanghai.aliyuncs.com/ua/promotion-thumb.png",
            "startAt"       => "2024-10-17T00:00:00+08:00",
            "vidName"       => "篮球",
            "vidUrl"        => "1"
        ];
        return $data;
    }

    public function actionGoods(){
        $path = 'https://sh-oss-n.oss-cn-shanghai.aliyuncs.com/ua/goods/';

        $data['code'] = 10000;
        $data['data'] = [
            [
                "id"            => "1",
                "name"          => "UA运动帽",
                "wechatQrCode"  => $path."t1/1/qrcode.png",
                "price"         => "101",
                "picUrls"       => [
                    $path."t1/1/1.png"
                ],
                "customPicUrls" => [$path."t1/1/thumb.png"],
            ],

            [
                "id"            => "2",
                "name"          => "户外骑行包",
                "wechatQrCode"  => $path."t1/2/qrcode.png",
                "price"         => "102",
                "picUrls"       => [
                    $path."t1/2/1.png",
                    $path."t1/2/2.png"
                ],
                "customPicUrls" => [$path."t1/2/thumb.png"],
            ],

            [
                "id"            => "3",
                "name"          => "UA运动鞋",
                "wechatQrCode"  => $path."t1/3/qrcode.png",
                "price"         => "103",
                "picUrls"       => [
                    $path."t1/3/1.png",
                    $path."t1/3/2.png",
                    $path."t1/3/3.png"
                ],
                "customPicUrls" => [$path."t1/3/thumb.png"],
            ],

            [
                "id"            => "4",
                "name"          => "中强度运动内衣",
                "wechatQrCode"  => $path."t1/4/qrcode.png",
                "price"         => "104",
                "picUrls"       => [
                    $path."t1/4/1.png",
                    $path."t1/4/2.png",
                    $path."t1/4/3.png",
                    $path."t1/4/4.png"
                ],
                "customPicUrls" => [$path."t1/4/thumb.png"],
            ],

            [
                "id"            => "5",
                "name"          => "跑步浅口袜",
                "wechatQrCode"  => $path."t1/5/qrcode.png",
                "price"         => "105",
                "picUrls"       => [
                    $path."t1/5/1.png",
                    $path."t1/5/2.png",
                    $path."t1/5/3.png",
                    $path."t1/5/4.png",
                    $path."t1/5/5.png"
                ],
                "customPicUrls" => [$path."t1/5/thumb.png"],
            ],

            [
                "id"            => "6",
                "name"          => "跑步短T恤",
                "wechatQrCode"  => $path."t1/6/qrcode.png",
                "price"         => "106",
                "picUrls"       => [
                    $path."t1/6/1.png",
                    $path."t1/6/2.png"
                ],
                "customPicUrls" => [$path."t1/6/thumb.png"],
            ],

            [
                "id"            => "7",
                "name"          => "户外空气沙发",
                "wechatQrCode"  => $path."t1/7/qrcode.png",
                "price"         => "107",
                "picUrls"       => [
                    $path."t1/7/1.png",
                    $path."t1/7/2.png"
                ],
                "customPicUrls" => [$path."t1/7/thumb.png"],
            ],

            [
                "id"            => "8",
                "name"          => "运动休闲鞋",
                "wechatQrCode"  => $path."t1/8/qrcode.png",
                "price"         => "108",
                "picUrls"       => [
                    $path."t1/8/1.png",
                    $path."t1/8/2.png"
                ],
                "customPicUrls" => [$path."t1/8/thumb.png"],
            ],

            [
                "id"            => "9",
                "name"          => "name 9",
                "wechatQrCode"  => $path."t1/8/qrcode.png",
                "price"         => "107",
                "picUrls"       => [
                    $path."t1/8/1.png",
                    $path."t1/8/2.png"
                ],
                "customPicUrls" => [$path."t1/8/thumb.png"],
            ],

            [
                "id"            => "10",
                "name"          => "name 10",
                "wechatQrCode"  => $path."t1/3/qrcode.png",
                "price"         => "108",
                "picUrls"       => [
                    $path."t1/3/1.png",
                    $path."t1/3/2.png"
                ],
                "customPicUrls" => [$path."t1/3/thumb.png"],
            ],

            [
                "id"            => "11",
                "name"          => "name 11",
                "wechatQrCode"  => $path."t1/2/qrcode.png",
                "price"         => "107",
                "picUrls"       => [
                    $path."t1/8/1.png",
                    $path."t1/8/2.png"
                ],
                "customPicUrls" => [$path."t1/2/thumb.png"],
            ],

            [
                "id"            => "12",
                "name"          => "name 12",
                "wechatQrCode"  => $path."t1/3/qrcode.png",
                "price"         => "108",
                "picUrls"       => [
                    $path."t1/3/1.png",
                    $path."t1/3/2.png"
                ],
                "customPicUrls" => [$path."t1/3/thumb.png"],
            ],

            [
                "id"            => "13",
                "name"          => "name 13",
                "wechatQrCode"  => $path."t1/3/qrcode.png",
                "price"         => "108",
                "picUrls"       => [
                    $path."t1/3/1.png",
                    $path."t1/3/2.png"
                ],
                "customPicUrls" => [$path."t1/3/thumb.png"],
            ],
        ];


        return $data;
    }

}
